/**
 * Created by lt on 2017/5/10.
 */
$(function () {

    $("#organizationAdd").click(function () {
        $("#form-organization-add").ajaxSubmit({
            type: "POST",
            url: '/organization/modifyOrganization.html',
            data: $('#form-organization-add').serialize(),// 你的formid
            dataType:"json",
            error: function (request) {
                alert("Connection error");
            },
            beforeSend: function () {
                console.log("begin...............");
                $(".loading").show();

            },
            success: function (data) {
                console.log(data);
                if (data.code != 0) {
                    layer.msg('操作成功!', {icon: 6, time: 1000}, function () {
                        console.log(data);
                        window.parent.location.reload();
                        var index = parent.layer.getFrameIndex(window.name);
                        parent.layer.close(index);
                    })
                }

            },
            complete: function (XMLHttpRequest, textStatus) {
                // alert('远程调用成功，状态文本值：'+textStatus);
                console.log("end...............");
                $(".loading").hide();
            },
        });

    })
});


function deleteOrganization(tid){
    $.ajax({
        type: "POST",
        url: '/organization/deleteOrganization.html',
        data: {"tid":tid},// 你的formid
        dataType:"json",
        success: function (data) {
            console.log(data);
            if (data.code != 0) {
                layer.msg('停用成功!', {icon: 6, time: 1000}, function () {
                    console.log(data);
                    window.location.reload();
                })
            }

        },
    });
}
function operateOrganization(tid){
    $.ajax({
        type: "POST",
        url: '/organization/operateOrganization.html',
        data: {"tid":tid},// 你的formid
        dataType:"json",

        success: function (data) {
            console.log(data);
            if (data.code != 0) {
                layer.msg('启用成功!', {icon: 6, time: 1000}, function () {
                    console.log(data);
                    window.location.reload();
                })
            }

        },
    });
}
function resetPassword(tid){
    $.ajax({
        type: "POST",
        url: '/organization/resetPassword.html',
        data: {"tid":tid},// 你的formid
        dataType:"json",

        success: function (data) {
            console.log(data);
            if (data.code != 0) {
                layer.msg('重置成功!', {icon: 6, time: 1000}, function () {
                    console.log(data);
                    window.location.reload();
                })
            }
        },
    });
}